<template>
  <a-row :gutter="10">
    <a-col :md="12" :sm="24">
      <a-card :bordered="false">
        <!-- 操作按钮区域 -->
        <h1>重要信访填写</h1>
        <div class="table-operator">
          <a-button @click="handleEdit('新增',null)" type="primary" icon="plus" >新增</a-button>
        </div>
        <a-table
          ref='table'
          size='middle'
          bordered
          childrenColumnName='childrenColumnName'
          :columns='columns'
          :dataSource='dataSource2'
          :loading='loading'
          :pagination="false"
          :scroll={y:600}
        >
          <span slot='action' slot-scope='text, record,index'>
            <a @click="handleEdit('编辑',record)"> 编辑 </a>
            <a-divider type='vertical' />
            <a  @click="handleDel(record.id)"> 删除 </a>
            </span>
        </a-table>


      </a-card>

    </a-col>
    <a-col :md="12" :sm="24">
      <a-card :bordered="false">
        <h1>信访构成一览表</h1>
        <a-alert type="info" >
          <template slot='message'>
            <a-row >
              <a-col :span='8'>总工单：{{ statistics.total }}</a-col>
              <a-col :span='8'>办结率：{{statistics.completionRate}}</a-col>
              <a-col :span='8'>环比：{{statistics.annulus}}</a-col>
            </a-row>
          </template>
        </a-alert>
        <statistics-table ref='sTable' :data-source='dataSource' :layout-y='540'></statistics-table>
      </a-card>

    </a-col>
    <handle-order-edit-modal ref='editModal' :ds='ds' @update='loadDate2'></handle-order-edit-modal>
  </a-row>
</template>

<script>
import StatisticsTable from '@views/data-governance/smart-reports/epidemic-daily/components/StatisticsTable'
import ReportsEpidemicDailyService from '@/myService/ReportsEpidemicDailyService'
import HandleOrderEditModal from '@views/data-governance/smart-reports/epidemic-daily/components/HandleOrderEditModal'
import moment from 'moment'

export default {
  name: 'HandleAdd',
  components:{
    StatisticsTable,
    HandleOrderEditModal,
  },
  data(){
    return{
      ds:this.$route.query.ds,
      dataSource:[],
      dataSource2:[],
      loading:false,
      columns:[
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: (text, row, index) => 1 + index
        },
        {
          title: '诉求',
          dataIndex: 'content',
        },
        {
          title: '处置情况说明',
          dataIndex: 'contentExplain',
        },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          width: 150,
          scopedSlots: { customRender: 'action' }
        }
      ],
      statistics:{}
    }
  },
  created() {
    this.loadDate()
    this.loadDate2();
    this.getReportsEpidemicStatistics();
  },
  methods:{
    loadDate(){
      ReportsEpidemicDailyService.getCategoryTemplateStatistics(this.ds).then(res=>{
        if (res.success) {
          this.dataSource = res.result.records || res.result
        }
        else {
          this.$message.warning(res.message)
        }
      })
    },
    loadDate2(){
      this.loading=true;
      ReportsEpidemicDailyService.getReportsEpidemicHandleOrder(this.ds).then(res=>{
        if (res.success) {
          this.dataSource2 = res.result.records || res.result
        }
        else {
          this.$message.warning(res.message)
        }
      }).finally(()=>{
        this.loading=false;
      })
    },
    getReportsEpidemicStatistics(){
      ReportsEpidemicDailyService.getReportsEpidemicStatistics(this.ds).then(res=>{
        this.statistics=res.result
      })
    },
    handleEdit(title,item){
      this.$refs.editModal.open(title,item);
    },
    handleDel(id){
      ReportsEpidemicDailyService.delHandleOrder(id).then(res=>{
        if(res.result===true) {
          this.$message.success("删除成功")
          this.loadDate2()
        }
      })
    }
  }
}
</script>

<style scoped>

</style>